package com.iqiyi.pps.epg.web.timer;


import com.iqiyi.pps.epg.core.service.program.IProgramAsyncService;
import com.iqiyi.pps.epg.core.service.program.ProgramService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by karkarrotxu on 2015/12/23.
 */
public class AutoChangeTagTrigger {
    private static Logger logger = LoggerFactory.getLogger(AutoChangeTagTrigger.class);

    @Autowired
    private ProgramService programService;

    @Autowired
    private IProgramAsyncService programAsyncService;

    public void task() {
        logger.info("[AutoChangeTagTrigger] task start");
        long current = System.currentTimeMillis();
        List<Long> programIds  =  programService.findChangeTagProgramIds();
        try {
            for(Long programId :programIds ){
                programAsyncService.addChangeTag(programId);
            }
        } catch (Exception e) {
            logger.error("[AutoChangeTagTrigger] exception",e);
        }
        logger.info("[AutoChangeTagTrigger] task end cost:" + (System.currentTimeMillis() - current));
    }
}